<template>
  <view class="maintenance-records-container">
    <!-- 标题栏 -->
    <view class="header">
      <view class="back-btn" @tap="goBack">
        <text class="back-icon">←</text>
      </view>
      <text class="title">维修记录</text>
    
    </view>
    
    <!-- 标签切换 -->
    <view class="tabs">
      <view class="tab-item" :class="{ active: activeTab === 'ongoing' }" @tap="switchTab('ongoing')">
        <text class="tab-text">进行中</text>
      </view>
      <view class="tab-item" :class="{ active: activeTab === 'completed' }" @tap="switchTab('completed')">
        <text class="tab-text">已完成</text>
      </view>
    </view>
    
    <!-- 筛选器 -->
    <view class="filter-bar">
      <view class="filter-item">
        <text class="filter-label">维修方式：</text>
        <text class="filter-value">{{ repairMethod }}</text>
        <text class="filter-arrow">▼</text>
      </view>
      <view class="filter-item date-filter">
        <text class="calendar-icon">📅</text>
        <text class="filter-label">预约日期</text>
      </view>
    </view>
    
    <!-- 记录列表 -->
    <view class="records-list">
      <view class="record-item" v-for="(record, index) in records" :key="index">
        <view class="record-content">
          <view class="record-row">
            <text class="record-label">维修单号：</text>
            <text class="record-value">{{ record.orderNumber }}</text>
          </view>
          <view class="record-row">
            <text class="record-label">维修方式：</text>
            <text class="record-value">{{ record.repairType }}</text>
          </view>
          <view class="record-row">
            <text class="record-label">预约日期：</text>
            <text class="record-value">{{ record.appointmentDate }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      activeTab: 'ongoing', // 当前激活的标签：ongoing(进行中) 或 completed(已完成)
      repairMethod: '全部', // 维修方式筛选条件
      records: [
        // 模拟数据
        {
          orderNumber: '3535252',
          repairType: '到店维修',
          appointmentDate: '2022/11/10 11:00'
        },
        {
          orderNumber: '3535252',
          repairType: '上门取车',
          appointmentDate: '2022/11/10 11:00'
        },
        {
          orderNumber: '3535252',
          repairType: '到店维修',
          appointmentDate: '2022/11/10 11:00'
        }
      ]
    }
  },
  methods: {
    // 返回上一页
    goBack() {
      uni.navigateBack()
    },
    
    // 切换标签
    switchTab(tab) {
      this.activeTab = tab
      // 这里可以根据标签切换加载不同的数据
      // 例如：如果是已完成标签，加载已完成的维修记录
    },
    
    // 选择维修方式
    selectRepairMethod() {
      // 这里可以实现维修方式的选择逻辑
      const methods = ['全部', '到店维修', '上门取车']
      // 简单的实现，实际应用中可以使用选择器组件
      const currentIndex = methods.indexOf(this.repairMethod)
      const nextIndex = (currentIndex + 1) % methods.length
      this.repairMethod = methods[nextIndex]
    }
  },
  onLoad() {
    // 页面加载时可以获取维修记录数据
    // 这里使用的是模拟数据
  }
}
</script>

<style scoped>
.maintenance-records-container {
  background-color: #f5f5f5;
  min-height: 100vh;
}

/* 标题栏样式 */
.header {
  padding: 60rpx 0 30rpx 0;
  text-align: center;
  background-color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}

.back-btn {
  position: absolute;
  left: 30rpx;
  top: 50%;
  transform: translateY(-50%);
  padding: 10rpx;
  margin-top: 10px;
}

.back-icon {
  font-size: 40rpx;
  font-weight: bold;
}

.title {
  font-size: 36rpx;
  font-weight: bold;
  margin: auto;
}

.header-right {
  position: absolute;
  right: 30rpx;
  top: 50%;
  transform: translateY(-50%);
  padding: 10rpx;
  display: flex;
  align-items: center;
}

.more-icon,
.filter-icon {
  font-size: 32rpx;
  margin-left: 20rpx;
}

/* 标签切换样式 */
.tabs {
  background-color: #fff;
  display: flex;
  margin-bottom: 20rpx;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 20rpx 0;
  position: relative;
}

.tab-item.active {
  color: #1677ff;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 30%;
  width: 40%;
  height: 6rpx;
  background-color: #1677ff;
  border-radius: 3rpx;
}

.tab-text {
  font-size: 32rpx;
  font-weight: 500;
}

/* 筛选栏样式 */
.filter-bar {
  background-color: #fff;
  display: flex;
  padding: 20rpx 30rpx;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.filter-item {
  display: flex;
  align-items: center;
}

.filter-label {
  font-size: 28rpx;
  color: #333;
}

.filter-value {
  font-size: 28rpx;
  color: #666;
  margin-right: 8rpx;
}

.filter-arrow {
  font-size: 24rpx;
  color: #999;
}

.calendar-icon {
  font-size: 28rpx;
  margin-right: 8rpx;
}

/* 记录列表样式 */
.records-list {
  background-color: #fff;
}

.record-item {
  border-bottom: 20rpx solid #f5f5f5;
}

.record-content {
  padding: 30rpx;
}

.record-row {
  display: flex;
  margin-bottom: 20rpx;
  align-items: center;
}

.record-row:last-child {
  margin-bottom: 0;
}

.record-label {
  font-size: 28rpx;
  color: #666;
  width: 180rpx;
}

.record-value {
  font-size: 28rpx;
  color: #333;
  flex: 1;
}
</style>